/**
 * 
 */
package dms.dto;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import dms.model.Building;
import dms.model.role.DormSupervisor;

/**
 * @author 李健
 *
 */
public class BulletinDTO extends ActionForm {
	private Long id;
	private Long building;
	private Long dormSupervisor;
	private String title;
	private String content;
	private Date publishDate;
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	/**
	 * @return the building
	 */
	public Long getBuilding() {
		return building;
	}
	/**
	 * @param building the building to set
	 */
	public void setBuilding(Long building) {
		this.building = building;
	}
	/**
	 * @return the dormSupervisor
	 */
	public Long getDormSupervisor() {
		return dormSupervisor;
	}
	/**
	 * @param dormSupervisor the dormSupervisor to set
	 */
	public void setDormSupervisor(Long dormSupervisor) {
		this.dormSupervisor = dormSupervisor;
	}
	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}
	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}
	/**
	 * @return the content
	 */
	public String getContent() {
		return content;
	}
	/**
	 * @param content the content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}
	/**
	 * @return the publishDate
	 */
	public Date getPublishDate() {
		return publishDate;
	}
	/**
	 * @param publishDate the publishDate to set
	 */
	public void setPublishDate(Date publishDate) {
		this.publishDate = publishDate;
	}
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		ActionErrors errors = new ActionErrors();
		if (this.title == null || this.title.length() == 0) {
			errors.add("title", new ActionMessage("缺少标题", false));
		}
		if (this.content == null || this.content.length() == 0) {
			errors.add("content", new ActionMessage("缺少内容", false));
		}
		
		return errors;
	}
	
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.building = null;
		this.content = null;
		this.dormSupervisor = null;
		this.title = null;
		this.id = null;
		this.publishDate = null;
	}
}
